Skip to content

Conversation

SeppoTakalo
Copy link
Contributor

The C/R bit in the address field should be handled as explained in 5.2.1.2 in the spec (3GPP TS 127.010).

To detect if the frame is a command or a response, we need to know who was the initiator of the CMUX channel.

Initiator is the station that take the initiative to initialize
the multiplexer (i.e. sends the SABM command at DLCI 0 )

See the table from given section of the specification.

Also, on UIH frames 5.4.3.1 says

The frames sent by the initiating station have the C/R bit set to 1
and those sent by the responding station have the C/R bit set to 0.

NOTE: This is different than a C/R bit in the Type field.

@zephyrbot zephyrbot added the area: Tests Issues related to a particular existing or missing test label Oct 9, 2025
@zephyrbot zephyrbot requested a review from nashif October 9, 2025 14:38
Copy link
Contributor

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test case for this?

@SeppoTakalo
Copy link
Contributor Author

@bjarki-andreasen

Could we add a test case for this?

Good idea.
I added

ZTEST(modem_cmux, test_modem_cmux_invalid_cr)
{
	uint32_t events;
	int ret;

	/* We are initiator, so any CMD with CR set, should be dropped */
	modem_backend_mock_put(&bus_mock, cmux_frame_control_cld_cmd,
			       sizeof(cmux_frame_control_cld_cmd));

	modem_backend_mock_put(&bus_mock, cmux_frame_control_sabm_cmd,
			       sizeof(cmux_frame_control_sabm_cmd));


	events = k_event_wait_all(&cmux_event, (MODEM_CMUX_EVENT_CONNECTED | MODEM_CMUX_EVENT_DISCONNECTED),
				  false, K_MSEC(100));

	zassert_false(events, "Wrong CMD should have been ignored");
}

So the mock tries to send Close-Down command and open command, but C/R bit set, so those should be ignored because in the test setup the mock is not an initiator, so C/R should be 0.

@SeppoTakalo SeppoTakalo force-pushed the cmux_cr_fixes branch 2 times, most recently from 6b374d7 to 63578b8 Compare October 10, 2025 09:36
tomi-font
tomi-font previously approved these changes Oct 10, 2025
uint32_t events;
int ret;

/* We are initiator, so any CMD with CR set, should be dropped */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* We are initiator, so any CMD with CR set, should be dropped */
/* We are initiator, so any CMD with CR set should be dropped */

The C/R bit in the address field should be handled as explained
in 5.2.1.2 in the spec (3GPP TS 127.010).

To detect if the frame is a command or a response,
we need to know who was the initiator of the CMUX channel.

>    Initiator is the station that take the initiative to initialize
>    the multiplexer (i.e. sends the SABM command at DLCI 0 )

See the table from given section of the specification.

Also, on UIH frames 5.4.3.1 says
>    The frames sent by the initiating station have the C/R bit set to 1
>    and those sent by the responding station have the C/R bit set to 0.

NOTE: This is different than a C/R bit in the Type field.

Signed-off-by: Seppo Takalo <[email protected]>
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Modem area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants